﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Sakura.Games.StgFramework.Builder.Battles
{
	using Res = Properties.Resources;

	/// <summary>
	/// 表示一个阵营的关系。无法继承该类型。
	/// </summary>
	public sealed class FactionRelation : BindableBase
	{
		private Faction _Source;

		/// <summary>
		/// 获取或设置阵营关系的发起方。
		/// </summary>
		public Faction Source
		{
			get
			{
				return this._Source;
			}
			set
			{
				this._Source = value;
				this.OnPropertyChanged("Source");
			}
		}

		/// <summary>
		/// 阵营关系的目标方。
		/// </summary>
		private Faction _Target;

		/// <summary>
		/// 获取或设置阵营关系的目标方。
		/// </summary>
		public Faction Target
		{
			get
			{
				return this._Target;
			}
			set
			{
				this._Target = value;
				this.OnPropertyChanged("Target");
			}
		}

		/// <summary>
		/// 发起方对于目标方的态度。
		/// </summary>
		private FactionType _FactionType;

		/// <summary>
		/// 获取或设置发起方对于目标方的态度。
		/// </summary>
		public FactionType FactionType
		{
			get
			{
				return this._FactionType;
			}
			set
			{
				this._FactionType = value;
				this.OnPropertyChanged("FactionType");
			}
		}

		/// <summary>
		/// 获得对象指定列的错误信息。
		/// </summary>
		/// <param name="columnName">要获取的错误的列。</param>
		/// <returns>该列的错误信息。</returns>
		protected override string GetError(string columnName)
		{
			switch (columnName)
			{
				case "Source":
					if (this._Source == null)
					{
						return Res.ErrorFactionRelationSourceIsNull;
					}
					break;
				case "Target":
					if (this._Target == null)
					{
						return Res.ErrorFactionRelationTargetIsNull;
					}
					break;
				case "FactionType":
					switch (this._FactionType)
					{
						case FactionType.Self:
							return Res.ErrorFactionRelationFactionTypeIsSelf;
						case FactionType.Enemy:
						case FactionType.Friend:
						case FactionType.Neutral:
							break;
						default:
							return Res.ErrorFactionRelationFactionTypeNotValid;
					}
					break;
			}

			return base.GetError(columnName);
		}
	}
}
